import styled from 'styled-components'
import Icon from '@/components/Icon'
import { useMccStore } from '@/pages/manager/store'

interface WrapProps {
	nestingLevel: number
	isVip: boolean
	isOnline: boolean
	isMeeting: boolean
	isNameBlue: boolean
}
export const ItemLabelWrap = styled.div<WrapProps>`
	display: flex;
	align-items: center;
	height: 30px;
	box-sizing: border-box;
	padding-left: ${(props) => {
		if (props.isOnline && props.isMeeting) {
			return `${props.nestingLevel * 22 + 26}px`
		} else {
			return `${props.nestingLevel * 22 + (props.nestingLevel > 0 ? 10 : 0) + 26}px`
		}
	}};
	overflow: hidden;
	.icon-toggle {
		flex: 0 0 14px;
		margin-right: 7px;
	}
	.icon-checked {
		/* flex: 0 0 14px;
		margin-right: 7px; */
		position: absolute;
		top: 8px;
		left: ${(props) => {
			if (props.isOnline && props.isMeeting) {
				return `${props.nestingLevel * 22 + 6}px`
			} else {
				return `${props.nestingLevel * 22 + (props.nestingLevel > 0 ? 10 : 0) + 6}px`
			}
		}};
	}
	.avatar {
		flex: 0 0 24px;
		display: flex;
		align-items: center;
		position: relative;
		margin-right: 8px;
		.icon-often {
			position: absolute;
			bottom: -2px;
			right: 0;
		}
	}
	.vip {
		flex: 0 0 26px;
		height: 15px;
		background-color: #5eb9ef;
		color: #ffffff;
		line-height: 15px;
		text-align: center;
		margin-right: 8px;
	}
	.name {
		color: ${(props) =>
			props.isOnline ? (props.isNameBlue ? `#2C8DC5` : `#000`) : props.isVip ? `#4e4e4e` : `#959697`};
		overflow: hidden;
		&.active-polling {
			color: #2bb7ff;
			font-weight: bold;
		}
		pre {
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}
	}
`
interface IconToggleProps {
	open: boolean
}
export const IconToggle = styled(Icon)<IconToggleProps>`
	width: 14px;
	height: 14px;
	background-position: ${(props) => (props.open ? `1px -1084px` : `-56px -1084px`)};
`
export const IconOftenMt = styled(Icon)`
	width: 11px;
	height: 11px;
	background-position: 0 -1767px;
`
export const IconTableCheckbox = styled(Icon)<{ checked: boolean; canChecked: boolean; flag: boolean }>`
	width: 14px;
	height: 14px;
	opacity: ${(props) => {
		const superMtNum = useMccStore.getState().mccInfo.superMtNum
		if (superMtNum === 1) {
			if (props.flag) {
				return 1
			} else {
				return props.canChecked ? 1 : 0.2
			}
		} else {
			return 1
		}
	}};
	cursor: ${(props) => {
		const superMtNum = useMccStore.getState().mccInfo.superMtNum
		if (superMtNum === 1) {
			if (props.flag) {
				return `auto`
			} else {
				return props.canChecked ? `auto` : `not-allowed`
			}
		} else {
			return `auto`
		}
	}};
	background-position: ${(props) => (props.checked ? `-38px -1671px` : `-2px -1671px`)};
`
